//
//  StasticsHeader.m
//  PropertyMananger
//
//  Created by bh on 17/1/16.
//  Copyright © 2017年 BH. All rights reserved.
//

#import "StasticsHeader.h"

@implementation StasticsHeader

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.bgView = [[UIImageView alloc]init];
        [self addSubview:self.bgView];
     //   self.bgView.backgroundColor = BHRandColor;
        
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.equalTo(self).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW, 260));
        }];
        
        UIImageView * yearIcon = [[UIImageView alloc]init];
        [self.bgView addSubview:yearIcon];
        self.bgView.userInteractionEnabled = YES;
        
        yearIcon.image = IMG(@"ico_statistics_detailed");
        [yearIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self.bgView).with.offset(15);
            make.top.equalTo(self.bgView).with.offset(15);
            make.size.mas_equalTo(CGSizeMake(20, 25));
        }];
        
        UILabel * yearDetailLabel = [[UILabel alloc]init];
        [self.bgView addSubview:yearDetailLabel];
        yearDetailLabel.text = @"年度详细";
        
        yearDetailLabel.textColor = BHColor(51, 51, 51);
        yearDetailLabel.font = BHFont(15);
        yearDetailLabel.textAlignment = NSTextAlignmentLeft;
        
        [yearDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(yearIcon.mas_trailing).with.offset(10);
            make.centerY.equalTo(yearIcon).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(100, 25));
        }];
        
        self.monthButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.bgView addSubview:self.monthButton];
        [self.monthButton setImage:IMG(@"ico_statistics_month") forState:UIControlStateNormal];
        //点击选择月份
       // [self.monthButton addTarget:self action:@selector(selectedMonth:) forControlEvents:UIControlEventTouchUpInside];
        
        [self.monthButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.trailing.equalTo(self.bgView).with.offset(-15);
            make.top.equalTo(self.bgView).with.offset(15);
            make.size.mas_equalTo(CGSizeMake(30, 30));
        }];
        
        self.yearLabel = [[UILabel alloc]init];
        [self.bgView addSubview:self.yearLabel];
        
        self.yearLabel.textAlignment = NSTextAlignmentRight;
        self.yearLabel.textColor = BHColor(102, 102, 102);
        self.yearLabel.font = BHFont(15);
        self.yearLabel.text = @"2017年/1月份";
        
        [self.yearLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.trailing.equalTo(self.monthButton.mas_leading).with.offset(-15);
            make.top.equalTo(self.monthButton).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/3+10, 25));
        }];
        
    }
    return self;
}

@end
